package net.cloudcodex.client.home.view;

import java.util.Date;

import net.cloudcodex.client.home.view.panel.HomeNotificationsPanel;
import net.cloudcodex.client.home.view.panel.campaign.HomeCampaignsPanel;
import net.cloudcodex.client.home.view.panel.character.HomeCharactersPanel;
import net.cloudcodex.client.home.view.panel.header.HomeHeaderPanel;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.inject.Inject;

/**
 * 
 * 
 * @author ADaroussin
 */
public class HomeViewImpl extends ScrollPanel implements HomeView {

	private final Message message;

	private FlowPanel innerpanel = new FlowPanel();

	private final HomeHeaderPanel homeHeaderPanel;

	private final HomeNotificationsPanel homeNotificationPanel;

	private final HomeCharactersPanel homeCharacterPanel;

	private final HomeCampaignsPanel homeCampaignPanel;

	@Inject
	public HomeViewImpl(Message message) {
		this.message = message;
		this.add(innerpanel);
		homeHeaderPanel = new HomeHeaderPanel();
		homeNotificationPanel = new HomeNotificationsPanel(message);
		homeCharacterPanel = new HomeCharactersPanel();
		homeCampaignPanel = new HomeCampaignsPanel();
		homeHeaderPanel.setMessage(message);
		homeCharacterPanel.setMessage(message);
		homeCampaignPanel.setMessage(message);
	}

	@Override
	public void initHomePage() {
		innerpanel.add(homeHeaderPanel);
		innerpanel.add(homeNotificationPanel);
		innerpanel.add(homeCharacterPanel);
		innerpanel.add(homeCampaignPanel);
	}

	@Override
	public void clearHomePage() {
		innerpanel.remove(homeHeaderPanel);
		innerpanel.remove(homeNotificationPanel);
		innerpanel.remove(homeCharacterPanel);
		innerpanel.remove(homeCampaignPanel);
	}

	@Override
	public void addNotifications(String message, Date dateNotif) {
		homeNotificationPanel.addNotification(message, dateNotif);

	}

	@Override
	public void addNickName(String nickname) {
		homeHeaderPanel.addNickName(nickname);
	}

	@Override
	public void addChararacterView(HomeCharacterView characterView) {
		homeCharacterPanel.addView(characterView);
	}

	@Override
	public void addCampaignView(HomeCampaignView campaignView) {
		homeCampaignPanel.addView(campaignView);

	}

	@Override
	public void initView() {
		homeCharacterPanel.initComponents();
		homeCampaignPanel.initComponents();

	}

	@Override
	public HasClickHandlers getAddCampaignButton() {
		return homeCampaignPanel.getAddCampaignButton();
	}

	// ----------------- Partie non encore implement�e ------------------
	// @Override
	// public void addInscriptions(List<CampaignRegistrationDTO> inscriptions) {
	// homeNotificationPanel.addInscriptions(inscriptions);
	// }
	//
	// @Override
	// public void addInvitations(List<CampaignInvitationDTO> invitations) {
	// homeNotificationPanel.addInvitations(invitations);
	// }
	// -------------------------------------------------------------------
}
